import time
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.service import Service

from pages.page_login import Login
from pages.page_open_backend import TestopenBackend


@pytest.fixture
def wed_driver():
    path = r"C:\Program Files\Python311\chromedriver.exe"  # 定义驱动路径
    ser = Service(executable_path=path)  # 实例化Chrome浏览器服务驱动
    driver = webdriver.Chrome(service=ser)  # 打开Chrome浏览器
    # 设置浏览器最大化
    driver.maximize_window()
    driver.implicitly_wait(10)
    yield driver
    time.sleep(2)
    driver.quit()


@pytest.fixture
def a_login(wed_driver):
    logging_page = Login(wed_driver)
    logging_page.open_url()
    logging_page.login('13002222221', '1q2w3e')


def wed_Backend_login(wed_driver):
    logging_page = TestopenBackend(wed_driver)
    logging_page.open_url_01()
    logging_page.Admin_Login('admin', 'HM_2025_test', '8888')
